/**
 * @auhtor	Nguyen Xuan Hung
 * @date	28.02.2011
 */
function open_form(url)
{
	$('#light_adct').html('').show();
	load_content('light_adct', url);
	$('#fade_adct').show();
}

function album_status(album_id, status)
{
	$.post(admin_url+'album/change_status', 'album_id='+album_id+'&status='+status, function(msg) {
		if(msg == "yes") {
			load_content('row_'+album_id, admin_url+'album/load_row/'+album_id);
            $('.linecate2').has('#row_'+album_id).css('background-color', '#FFFFE0');
		}
	});
}

function album_delete(album_id)
{
    if(!confirm('Are you sure ?')) {
        return false;
    }
    
	$.post(admin_url+'album/delete/'+album_id, function(msg) {
		if(msg == "yes") {
			$('div.linecate2').has('#row_'+album_id).fadeOut('slow').remove();
		}
	});
}

function news_status(id, status, type)
{
	$.post(admin_url+'news/change_status', 'id='+id+'&status='+status+'&type='+type, function(msg) {
		if(msg == "yes") {
			load_content('row_'+id, admin_url+'news/load_row/'+id+'/'+type);
            $('.linecate2').has('#row_'+id).css('background-color', '#FFFFE0');
		}
	});
}

function news_delete(id, type)
{
    if(!confirm('Are you sure ?')) {
        return false;
    }
    
	$.post(admin_url+'news/delete', 'id='+id+'&type='+type, function(msg) {
		if(msg == "yes") {
			$('div.linecate2').has('#row_'+id).fadeOut('slow').remove();
		}
	});
}

function user_status(user_id, status)
{
	$.post(admin_url+'user/change_status', 'user_id='+user_id+'&status='+status, function(msg) {
		if(msg == "yes") {
			load_content('row_'+user_id, admin_url+'user/load_row/'+user_id);
            $('.linecate2').has('#row_'+user_id).css('background-color', '#FFFFE0');
		}
	});
}

function user_delete(user_id)
{
    if(!confirm('Are you sure ?')) {
        return false;
    }
    
	$.post(admin_url+'user/delete/', 'id='+user_id, function(msg) {
		if(msg == "yes") {
			$('div.linecate2').has('#row_'+user_id).fadeOut('slow').remove();
		}
	});
}

function email_status(id, status)
{
	$.post(admin_url+'email_temp/change_status', 'id='+id+'&status='+status, function(msg) {
		if(msg == "yes") {
			load_content('row_'+id, admin_url+'email_temp/load_row/'+id);
            $('.linecate2').has('#row_'+id).css('background-color', '#FFFFE0');
		}
	});
}

function email_delete(id)
{
    if(!confirm('Are you sure ?')) {
        return false;
    }
    
	$.post(admin_url+'email_temp/delete/', 'id='+id, function(msg) {
		if(msg == "yes") {
			$('div.linecate2').has('#row_'+id).fadeOut('slow').remove();
		}
	});
}

function destination_status(id, status)
{
	$.post(admin_url+'destination/change_status', 'id='+id+'&status='+status, function(msg) {
		if(msg == "yes") {
			load_content('row_'+id, admin_url+'destination/load_row/'+id);
            $('.linecate2').has('#row_'+id).css('background-color', '#FFFFE0');
		}
	});
}

function destination_delete(id)
{
    if(!confirm('Are you sure ?')) {
        return false;
    }
    
	$.post(admin_url+'destination/delete/', 'id='+id, function(msg) {
		if(msg == "yes") {
			$('div.linecate2').has('#row_'+id).fadeOut('slow').remove();
		}
	});
}

function load_content(div_return, url)
{
	var waiting = false;
	if(arguments[2] == true) waiting = true;
	if(waiting == true) $('#waiting').show();
	
	$("#"+div_return).load(url, function() {
    	$('#waiting').fadeOut();
	});
}

function add_more_image()
{
	var new_image = '<li>';
		new_image += '<span class="left">&nbsp;</span>';
		new_image += '<span class="right">';
		new_image += '<input type="text" name="images_name[]" value="" style="margin:0; width:60%;" /> <span style="padding:0 5px;"> - </span><input type="file" name="images[]" value="" /><br /><textarea name="images_description[]"  style="margin:0; width:60%;"></textarea>';
		new_image += '</span>';
		new_image += '</li>';
	$('#add_more').before(new_image);
}

function content_filter(url)
{
    keyword = $('#keyword').val();
    if(keyword == 'Keyword') keyword = '';
	window.location.href = url + '?keyword='+keyword+'&cat_id='+$('#cat_id').val();
}